package binaryTree;

/**
 * 平衡二叉树判断
 */
public class isBlanced {
    private int leftHeight;
    private int rightHeight;
    public Boolean isBlancedTset(TreeNode root){
        if(root==null){
            return null;
        }
        if (!isBlancedTset(root.left)||!isBlancedTset(root.right)){
            return false;
        }
        maxDepth maxDepth=new maxDepth();
        leftHeight=maxDepth.findMaxDepth(root.left)+1;
        rightHeight=maxDepth.findMaxDepth(root.right)+1;
        if (Math.abs(leftHeight-rightHeight)>1){
            return false;
        }
        else{
            return true;
        }
    }
}
